package com.yunsc.store.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunsc.store.entity.YunscRegionEntity;
import com.yunsc.store.vo.AddressRegionVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.Map;

/**
 * 省市区数据表
 * 
 * @author adan
 * @email 2028038953@qq.com
 * @date 2024-04-22 11:35:51
 */
@Mapper
public interface YunscRegionDao extends BaseMapper<YunscRegionEntity> {
    @Select("SELECT\n" +
            "    t3.name AS region,\n" +
            "    t2.name AS city,\n" +
            "    t1.name AS province\n" +
            "FROM\n" +
            "    yunsc_region t3\n" +
            "        JOIN yunsc_region t2 ON t3.pid = t2.id\n" +
            "        JOIN yunsc_region t1 ON t2.pid = t1.id\n" +
            "WHERE\n" +
            "        t3.id = #{regionId}")
    Map<String, Object> getAddressByOrderId(Integer regionId);

    @Select("SELECT\n" +
            "    t3.name AS region,\n" +
            "    t2.name AS city,\n" +
            "    t1.name AS province\n" +
            "FROM\n" +
            "    yunsc_region t3\n" +
            "        JOIN yunsc_region t2 ON t3.pid = t2.id\n" +
            "        JOIN yunsc_region t1 ON t2.pid = t1.id\n" +
            "WHERE\n" +
            "        t3.id = #{regionId}")
    AddressRegionVO getAddressVOByOrderId(Integer regionId);
}
